export const withDelayRequest = <T extends (...args: [...any]) => Promise<any>>(apiFn: T, delay = 300): T => {
  return (async (...args: any) => {
    const start = Date.now()
    const result = await apiFn(...args)
    const requestDuration = Date.now() - start
    const remainingDelay = Math.max(0, delay - requestDuration)
    return new Promise(resolve => setTimeout(() => resolve(result), remainingDelay))
  }) as any
}
